<!DOCTYPE html>
<svg width="400" height="100">
  <filter id="notFirst">
    <feFlood flood-color="green"/>
    <feComposite in2="SourceGraphic" in="unknown" operator="atop"/>
  </filter>
  <filter id="notFirstEmpty">
    <feFlood flood-color="green"/>
    <feComposite in2="SourceGraphic" in="" operator="atop"/>
  </filter>
  <filter id="first">
    <feComposite in2="SourceGraphic" in="unknown" operator="atop"/>
  </filter>
  <filter id="firstEmpty">
    <feComposite in2="SourceGraphic" in="" operator="atop"/>
  </filter>
  <rect width="100" height="100" fill="red" filter="url(#notFirst)"/>
  <rect x="100" width="100" height="100" fill="red" filter="url(#notFirstEmpty)"/>
  <rect x="200" width="100" height="100" fill="green" filter="url(#first)"/>
  <rect x="300" width="100" height="100" fill="green" filter="url(#firstEmpty)"/>
</svg>
